package protocol.JT808_2019;

import java.util.HashMap;

public class Handle808_2019JT87 implements IHandle808_2019JT {
    @Override
    public String handle(JT808_2019Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x00:
                return handle8700(cmd);
            case 0x01:
                return handle8701(cmd);
            case 0x02:
                return handle8702(cmd);
            default:
                return "808-2019:未匹配的命令字"+(cmd.readOrder()+","+cmd.readSubOrder());
        }
    }

    private String handle8702(JT808_2019Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:上报驾驶员身份信息请求");
        builder.append("\r\n");
        return builder.toString();
    }

    private String handle8701(JT808_2019Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:行驶记录参数下传命令");
        builder.append("\r\n");
        builder.append("命令字:"+cmd.readBCD(1));
        builder.append("\r\n");
        builder.append("数据:"+cmd.readBCD(cmd.leftSize()));

        return builder.toString();
    }

    private String handle8700(JT808_2019Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:行驶记录数据采集命令");
        builder.append("\r\n");
        builder.append("命令字:"+cmd.readBCD(1));
        builder.append("\r\n");
        builder.append("数据:"+cmd.readBCD(cmd.leftSize()));

        return builder.toString();
    }
}
